<!--
 * @Author: hucc
 * @Date: 2021-10-12 14:26:29
 * @LastEditors: hucc
 * @LastEditTime: 2021-10-12 14:34:52
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="app">
        <my-com>
            <!-- scope 作用域对象 封装了子组件向上暴露的数据,方便父组件拿到数据 -->
            <!-- scope 对象可以进行解构 -->
            <template v-slot:header="{msg,userInfo}">
                {{msg}}---{{userInfo}}
                <h3>我是头部</h3>
            </template>

            <h4>我是体部</h4>
            <template v-slot:footer>
            <h5>我是底部</h5>
           </template>

        </my-com>
    </div>
    <script>
        let component1 = {
            data() {
                return {
                    msg: '我是子组件数据',
                    userInfo: {
                        username: 'zs',
                        password: '123321'
                    }
                }
            },
            template: `
            <div>
                  <header><slot name='header' v-bind:msg='msg' :userInfo="userInfo"></slot></header>
                  <main><slot name='default'></slot></main>
                  <footer><slot name='footer'></slot></footer>
                </div>
            `
        }
        let vm = new Vue({
            el: '#app',
            data: {

            },
            methods: {},
            created() {},
            components: {
                'myCom': component1
            }
        })
    </script>
</body>

</html>